{% extends 'base.html' %}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
{% block title %}
    博客首页
{% endblock %}


{% block styles %}
    {{ super() }}
    <style>

        #container {
            width: 1000px;
            margin: 0 auto;

        }

        .article {
            width: 90%;
            margin: 20px auto;
            padding: 5px 10px;
            background-color: rgba(131, 202, 227, 0.7);
            border-bottom: 1px solid gray;
        }

        .article p {
            font-size: 14px;
        rgba(75, 75, 74, 1.00);
        }

        .article p span {
            color: #1a1a1a;
        }

        .article h4 a {
            /*color: rgba(80, 80, 79, 1.00);*/
            color: #1a1a1a;
        }

        .article div span {
            margin-left: 20px;
            color: #1a1a1a;
        }

        .article div {
            margin-bottom: 18px;

        }


    </style>

{% endblock %}


{% block newcontent %}
    <div id="container">
        {% for article in pagination.items %}
            <div class="article">
                <h4><a href="{{ url_for('article.article_detail') }}?aid={{ article.id }}">{{ article.title }}</a></h4>
                <p>
                    <!--            通过文章找用户-->
                    <span>作者:{{ article.user.username }}</span>
                    <br>
                    <br>
                    <!--safe 过滤器不对文章的html进行转义-->
                <div>{{ article.content | cdecode | safe }}</div>
                </p>
                <div style="color: #1a1a1a">
                    <span style="margin-left: 0 ">发表时间:{{ article.padatetime }}</span>
                    <span>收藏:{{ article.save_num }}</span><span>点击量:{{ article.click_num }}</span>
                </div>
            </div>
        {% endfor %}
        <nav aria-label="Page navigation" class="col-md-offset-4">
            <ul class="pagination">
                <!--   pagination.prev_num 判断是否存在上一页，如果存在则可以点击，否则不能点击             -->
                <li {% if not pagination.prev_num %} class="disabled" {% endif %}><a
                        href="{{ url_for('user.index') }}?page={{ pagination.prev_num }}"
                        aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
                </li>
                {% for page_num in range(1,pagination.pages + 1) %}
                    <li {% if pagination.page== page_num %} class="active" {% endif %}><a
                            href="{{ url_for('user.index') }}?page={{ page_num }}">{{ page_num }} </a></li>
                {% endfor %}
                <!--   pagination.has_next 判断是否存在上一页，如果存在则可以点击，否则不能点击             -->
                <li {% if not pagination.has_next %} class="disabled" {% endif %}>
                    <a href="{{ url_for('user.index') }}?page={{ pagination.next_num }}" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
            </ul>
        </nav>
    </div>

{% endblock %}
